<template>
	<view class="charge">
		<view class="top">
			<text class="toptext">提现金额</text>
			<view class="topinput">
				￥<input type="number" placeholder="0.00" v-model="num" />
			</view>
		</view>
		<view class="charge_1">
			<text class="title">提至</text>
			<view class="charge_check">
				<view class="left">
					<image src="/static/index/yh1.png" mode=""></image>
					<view class="text">
						<text>银行卡</text>

					</view>
				</view>
				<view class="right">
					<label class="radio">
						<radio @click="changeradio(1)" :checked="radioShow === 1" />
					</label>
				</view>
			</view>

			<view class="charge_check">
				<view class="left">
					<image src="/static/index/wx.png" mode=""></image>
					<view class="text">
						<text>微信</text>

					</view>
				</view>
				<view class="right">
					<label class="radio">
						<radio @click="changeradio(2)" :checked="radioShow === 2" />
					</label>
				</view>
			</view>

			<view class="charge_check">
				<view class="left">
					<image src="/static/index/zfb.png" mode=""></image>
					<view class="text">
						<text>支付宝</text>

					</view>
				</view>
				<view class="right">
					<label class="radio">
						<radio @click="changeradio(3)" :checked="radioShow === 3" />
					</label>
				</view>
			</view>


		</view>
		<view class="bg" v-if="isSure">
			<view class="password">
				<view class="title">
					<text>请输入支付密码</text>
					<text @click="close">X</text>
				</view>
				<view class="password_input">
					<input type="password" v-model="password" placeholder="请输入支付密码"
						placeholder-style="font-size:14px;color:#777" />
				</view>
				<view class="getbtn">
					<view class="btn1" @click="sure">
						确认
					</view>
					<view class="btn2" @click="close">
						取消
					</view>
				</view>
			</view>
		</view>
		<view class="btn" @click="pay">
			确认提现
		</view>
		<view class="infolist">
			<view class="title">
				<view class="add_time">
					时间
				</view>
				<view class="num">
					数量
				</view>
				<view class="to_type">
					提至
					{{to_type[info.to_type]}}
				</view>
				<view class="num" >
					状态
				</view>
			</view>
			<view class="msg">
				<view class="msgitem" v-for="(item,index) in info" :key='index'>
					<view class="add_time">
						{{item.add_time}}
					</view>
					<view class="num">
						{{item.num}}
					</view>
					<view class="to_type">
						{{to_type[item.to_type]}}
					</view>
					<view class="num" v-if="item.status == 0">
						未处理
					</view>
					<view class="num" v-if="item.status == 1">
						已通过
					</view>
					<view class="num" v-if="item.status == 2">
						已驳回
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		UserWithdraw,
		UserWithdrawList
	} from '../../api/api.js'
	import fjjImages from '@/components/fjj-images/fjj-images.vue'
	export default {
		components: {
			fjjImages
		},
		data() {
			return {
				radioShow: 1,
				wximg: [],
				isSure: false,
				password: '',
				num: '',
				info: [],
				to_type: ['', '银行', '微信', '支付宝']
			}
		},
		onLoad() {
			this.UserWithdrawList()
		},
		methods: {
			UserWithdrawList() {
				UserWithdrawList().then(res => {
					this.info = res.data.record
				})
			},
			pay() {
				this.isSure = true
			},
			sure() {
				UserWithdraw({
					to_type: this.radioShow,
					num: this.num,
					password: this.password
				}).then(res => {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
					this.num = ''
					this.password = ''
					this.isSure = false
					this.UserWithdrawList()
					setTimeout(() => {
						if (res.status == 2) {
							uni.navigateTo({
								url: '/pages/userbank/index'
							})
						}
					}, 1000)
				})
			},
			close() {
				this.password = ''
				this.isSure = false
			},
			getwximgurl(e) {
				this.wximg = e
			},
			changeradio(i) {
				this.radioShow = i
			},
			editParkImg(currentTempFilePath) {},
			deleteImg(index) {},
		}
	}
</script>

<style lang="scss">
	.infolist {
		.title {
			display: flex;
			justify-content: space-between;

			view {
				width: 33%;
			}

		}

		.to_type {
			text-align: right;
		}

		.num {
			text-align: center;
		}

		.msg {
			.msgitem {
				view {
					width: 33%;
				}

				display: flex;
				justify-content: space-between;
				padding: 0 5%;
				line-height: 40px;
				font-size: 12px;
			}
		}
	}

	.charge {
		padding-bottom: 20rpx;

		.top {
			background: #fff;
			padding-bottom: 20px;

			.toptext {
				padding: 0 5%;
				line-height: 80px;
			}

			.topinput {
				display: flex;
				align-items: center;
				font-size: 20px;
				padding: 0 5%;

				input {
					margin-left: 5px;
					font-size: 20px;
					border-bottom: 1px solid #ccc;
				}
			}
		}

		.title {
			padding: 0 5%;
			line-height: 40px;
			font-size: 12px;
		}

		.charge_1 {
			background: #fff;
			margin-top: 20rpx;

			.bankinfo {
				font-size: 24rpx;
				padding: 10rpx 5%;
				padding-bottom: 0;

				.info {
					padding: 20rpx 0;
					border-bottom: 1px solid #efefef;
				}
			}

			.payimg {
				padding: 10px 0;

				image {
					width: 90%;
					margin-left: 5%;
				}
			}

			.charge_check {
				border-top: 1px solid #efefef;
				padding: 10px 10px;
				display: flex;
				justify-content: space-between;
				align-items: center;

				.left {
					display: flex;
					align-items: center;

					image {
						width: 70rpx;
						height: 70rpx;
					}

					.text {
						display: flex;
						flex-direction: column;
						font-size: 12px;
						margin-left: 10px;

						.num {
							color: #777;
						}
					}
				}
			}
		}

		.btn {
			margin: 50px auto;
		}
	}

	.bg {
		background: #00000033;
		position: absolute;
		top: 0;
		width: 100%;
		height: 100%;

		.password {
			background: #fff;
			position: absolute;
			width: 90%;
			left: 5%;
			top: 60vw;

			.title {
				display: flex;
				justify-content: space-between;
				padding: 4% 5%;
				font-size: 28rpx;
				background: #f8f8f8;
			}

			.password_input {
				border: 1px solid #ccc;
				width: 70%;
				margin: 70rpx auto;

				input {
					padding-left: 40rpx;
					height: 80rpx;
				}
			}

			.getbtn {
				display: flex;
				justify-content: flex-end;
				margin-top: 170rpx;
				padding-bottom: 40rpx;

				view {
					padding: 10rpx 30rpx;
					font-size: 28rpx;
				}

				.btn1 {
					background: #1E9FFF;
					color: #fff;
				}

				.btn2 {
					border: 1px solid #ccc;
					color: #777;
					margin: 0 40rpx;
				}
			}

		}
	}
</style>
